home *** CD-ROM | disk | FTP | other *** search
- STF A DOS Filter to Convert Files to Standard Text Format
- =================================================================
-
- In my data communications sessions with host computers, bulletin
- boards and electronic mail services I work in "text mode" 98% of
- the time. Only the remaining 2% is spent in protocol-controlled
- file transfer.
-
- Popular asynchronous data communications packages do a poor job
- of supporting these work habits. Specifically, "captured" data
- files are not forced to conform to any reasonable conventions.
- Anything and everything that comes across the communications
- channel ends up in the disk file. PC-Talk (unmodified),
- Crosstalk, Relay and Tymcomm do NOT enforce any conventions and
- are all GUILTY! (It can be argued that this is the appropriate
- mode of operation. Fine, just provide "text mode" rule
- enforcement on an optional basis.)
-
- Apparently every host computer and RBBS has established its own
- unique set of rules for line termination and control character
- transmission. With transparent "data capture" these rules are
- propagated to the PC where they make life miserable for
- application programs. Applications performing line-input file
- access are surprised to find imbedded ESCape sequences, lines
- longer than 254 characters and non-standard line-terminators.
-
- In frustration I established my own Standard Text File
- conventions.
-
- My first approach was to modify PC-TALK.III to include these
- rules so that post-processing would not be necessary. However,
- my expanded use of other communications software demanded a
- generalized solution. This is embodied in a DOS filter called
- STF (Standard Text Filter) which is designed to post-process
- files received by any asynchronous data communication packages.
-
- Remember, STF filtering rules apply to disk file data capture.
- Communications programs must apply different rules to data
- streams destined for the display screen (e.g. ESCape sequences)
- or the printer (e.g. Form Feeds).
-
-
- STF.PAS
- =======
-
- STF (Standard Text Filter) provides a conversion between files of
- arbitrary content and files conforming to the Standard Text File
- definition (see below).
-
- It is particularly useful in processing data files captured from
- host computers and bulletin board services. In addition to
- creating a predictable output file, STF will convert ASCII device
- and paper motion control sequences to printable ASCII characters.
-
- STF is written in Turbo Pascal and is on this conference as NOTE
- STF.PAS. A compiled version, NOTE STF.COM (in Tymcomm Image
- format), is also available.
-
-
- DEFINITIONS
- ===========
-
- Standard Text File: A DOS file of Standard Text Lines followed
- by an End-of-File marker.
-
- Standard Text Line: Zero to 254 ASCII Graphic Characters
- followed by a Carriage Return (X0D) and Line Feed (X0A).
-
- ASCII Graphic Character: Printable ASCII characters in the range
- Space (X20) through Tilde (X7E).
-
- End-of-File: A Control-Z (X1A) explicitly marks the end of a
- Standard Text File. A one-character DOS file containing a
- Control-Z is a valid Standard Text File.
-
- Line Buffer: An array of 254 characters used to construct the
- Standard Text Line.
-
- Buffer Pointer: The position of the last ASCII character
- inserted in the Line Buffer.
-
- Horizontal Paper Motion: ASCII control codes determining the
- left-to-right position of the next character to be processed.
-
- Vertical Paper Motion: ASCII control codes determining the
- top-to-bottom position of the next character to be processed.
-
-
- PROCESSING DETAILS
- ==================
-
- The following chart details the STF filtering actions for each
- input character:
-
-
- Dec Hex Char Name Comments
- --- --- ---- ---- -----------------------------------------
-
- 000 00 ^@ NUL Ignored
- 001 01 ^A SOH Ignored
- : : : Ignored
- 006 06 ^F ACK Ignored
- 007 07 ^G BEL Ignored
-
- 008 08 ^H BS Horizontal Paper Motion (Backspace):
- The Buffer Pointer is moved left one
- position. Backspacing beyond position 0
- leaves the Buffer Pointer positioned at 0.
-
- 009 09 ^I HT Horizontal Paper Motion (Horizontal Tab):
- The Buffer Pointer is moved right to the
- next 8-character tab stop (i.e. 9, 17, 25,
- 33, etc.). Intervening buffer positions
- are filled with spaces (X20). Tabbing
- beyond position 254 leaves the Buffer
- Pointer positioned at 254.
-
- 010 0A ^J LF Vertical Paper Motion (Line Feed):
- The Line Buffer is written and the Buffer
- Pointer is set to 0. See Note 1 below.
-
- 011 0B ^K VT Vertical Paper Motion (Vertical Tab):
- The Line Buffer is written, two zero-length
- lines are written, and the Buffer Pointer
- is set to 0.
-
- 012 0C ^L FF Vertical Paper Motion (Form Feed):
- The Line Buffer is written, a line
- containing '.pa' is written, and the Buffer
- Pointer is set to 0.
-
- 013 0D ^M CR Horizontal Paper Motion (Carriage Return):
- Ignored: Vertical Paper Motion is used to
- detect line-end.
-
- 014 0E ^N SO Ignored
- 015 0F ^O SI Ignored
- : : : Ignored
- 030 1E ^^ RS Ignored
- 031 1F ^_ US Ignored
-
- 032 20 SPC ASCII Graphic The Buffer Pointer
- 033 21 ! ASCII Graphic is moved right one
- 034 22 " ASCII Graphic position and the
- : : : ASCII Graphic character is inserted
- 124 7C | ASCII Graphic in the Line Buffer at
- 125 7D } ASCII Graphic that position. See
- 126 7E ~ ASCII Graphic Note 2 below.
-
- 127 7F DEL Same as BS (X08)
-
- 128 80 Same as NUL (X00) A character in the
- 129 81 Same as SOH (X01) range 128-255 is
- 130 82 Same as STX (X02) converted to the
- : : corresponding
- 253 FD Same as } (X7D) character in the
- 254 FE Same as ~ (X7E) range 000-127.
- 255 FF Same as DEL (X7F)
-
- --- --- ---- ---- -----------------------------------------
-
- Note 1: The Line Buffer is appended with a Carriage Return and
- Line Feed when written. Additionally, a Control-Z end-of-file
- marker is written after the last line in the output file.
-
- Note 2: Line "folding" will occur if the Line Buffer is moved
- past position 254 while processing ASCII Graphic Characters.
- Line "folding" is accomplished by 1) writing the "full" Line
- Buffer, 2) setting the Buffer Pointer to 1, and 3) inserting the
- new character in the Line Buffer at position 1.
-
- -----
-
- Joe Doran
-
- *** CREATED 10/26/84 09:02:42 BY $MS ***